
#ifndef _APDU_LIB_ECC_MGR_H_
#define _APDU_LIB_ECC_MGR_H_

#include "../apdu.def/apdu_datatypes.h"


#ifdef __cplusplus
extern "C" {
#endif

	int app_gen_ecc_keypair(HANDLE devHandle,int app_id, int container_id, int bits,
					unsigned char * pub_key_blob, int * key_blob_len);

	int app_import_ecc_keypair(HANDLE devHandle, int app_id, int container_id, 
							unsigned char * enveloped_key_blob, int key_blob_len);
	
	int app_import_ext_ecc_keypair(HANDLE devHandle, int app_id, int container_id, 
							int key_spec, unsigned char * ecc_key_blob, int key_blob_len);
	
	int app_ecc_sign_data( HANDLE devHandle,int app_id, int container_id, int input_mode,
						unsigned char * user_id, int id_len,
						unsigned char * input_data, int input_len,
						unsigned char * signature, int * sig_len);

	int app_ecc_sign_data_ex( HANDLE devHandle,int app_id, int container_id, int input_mode, int key_spec,
						unsigned char * user_id, int id_len,
						unsigned char * input_data, int input_len,
						unsigned char * signature, int * sig_len);

	int app_ecc_sign_data_interactive( HANDLE devHandle,int app_id, int container_id,
									int input_mode, int key_spec, int timeout,
									unsigned char * user_id, int id_len,
									unsigned char * input_data, int input_len,
									unsigned char * signature, int * sig_len);

	int app_ecc_sign_data_interactive_cancel( HANDLE devHandle,int app_id, int container_id, int input_mode, int key_spec);


	int app_ecc_verify(HANDLE devHandle,unsigned char * ecc_pub_key_blob, int key_blob_len,
						unsigned char * input_data, unsigned long input_len, 
						unsigned char * ecc_signature_blob, int sig_blob_len );

	int app_ecc_export_session_key(HANDLE devHandle, int app_id, int container_id, unsigned long alg_id,
						unsigned char * ecc_pub_key_blob, unsigned long key_blob_len,
						unsigned char * encipher_blob, int *encipher_blob_len, 
						int * session_key_id);


	int app_ecc_export_session_key_ex(HANDLE devHandle,int app_id, int container_id, int session_key_id,
						unsigned char * ecc_pub_key_blob, unsigned long key_blob_len, 
						unsigned char * encipher_blob, int *encipher_blob_len);

	int app_ecc_export_session_key2( HANDLE devHandle,int app_id, int container_id, int session_key_id,
						unsigned char * ecc_pub_key_blob, unsigned long key_blob_len,
						unsigned char * encipher_blob, int *encipher_blob_len);

	int app_ext_ecc_encrypt(HANDLE devHandle,unsigned char * ecc_pub_key_blob, unsigned long key_blob_len, 
						unsigned char * input_data, unsigned long input_len,
						unsigned char * encipher_blob, int *encipher_blob_len);

	int app_gen_agreement_data_with_ecc(HANDLE devHandle,int ap_id, int container_id, UINT32 alg_id, 
						unsigned char * user_id, int id_len, 
						unsigned char * tmp_ecc_pub_key_blob, UINT32 key_blob_len, 
						UINT32 * agreement_handle);


	int app_gen_agreement_data_and_key_with_ecc(HANDLE devHandle,int app_id, int container_id, unsigned long alg_id,
					unsigned char * sponsor_pub_key_blob, unsigned long sponsor_key_blob_len, 
					unsigned char * sponsor_tmp_pub_key_blob, unsigned long sponsor_tmp_key_blob_len,
					unsigned char * sponsor_id, int sponsor_id_len, 
					unsigned char * responser_id, int responser_id_len, 
					unsigned char * responser_tmp_pub_key_blob, unsigned int *responser_tmp_key_blob_len, 
					int * session_key_id);

	int app_gen_agreement_data_and_key_with_ecc_ex( HANDLE devHandle,int app_id, int container_id, 
					int key_spec, unsigned long alg_id,
					unsigned char * sponsor_pub_key_blob, unsigned long sponsor_key_blob_len, 
					unsigned char * sponsor_tmp_pub_key_blob, unsigned long sponsor_tmp_key_blob_len,
					unsigned char * sponsor_id, int sponsor_id_len, 
					unsigned char * responser_id, int responser_id_len,
					unsigned char * responser_tmp_pub_key_blob, unsigned int *responser_tmp_key_blob_len, 
					int * session_key_id );

	int app_gen_key_with_ecc(HANDLE devHandle, int app_id, int container_id, unsigned long agreement_handle, 
						unsigned char * pub_key_blob, unsigned long key_blob_len, 
						unsigned char * tmp_key_blob, unsigned long tmp_key_blob_len,
						unsigned char * responser_id, int responser_id_len,
						int * session_key_id);

	int app_gen_key_with_ecc_ex( HANDLE devHandle,int app_id, int container_id, int key_spec,
						unsigned long agreement_handle, unsigned char * pub_key_blob,
						unsigned long key_blob_len, unsigned char * tmp_key_blob,
						unsigned long tmp_key_blob_len, unsigned char * responser_id, int responser_id_len,
						int * session_key_id);

	int	app_ecc_private_decrypt(HANDLE devHandle, int app_id, int container_id, int key_spec,
						unsigned char * input_data, unsigned long input_len,
						unsigned char * encipher_blob, int *encipher_blob_len);

	int app_gen_ext_ecc_keypair(HANDLE devHandle, unsigned char * prikey_blob, int * blob_len);

	int app_export_ext_ecc_pubkey(HANDLE devHandle, unsigned char * pubkey_blob, int * blob_len);

	int app_import_ecc_keypair_to_ram(HANDLE devHandle, unsigned char * ecc_keypair_blob, int blob_len);

	int app_ram_ecc_sign(HANDLE devHandle, unsigned char * input, int input_len,
						unsigned char * signature_data, int * siganature_len);

	int app_ram_ecc_decrypt(HANDLE devHandle, unsigned char * cipher_data, int cipher_len, unsigned char * plain_data, int * plain_len);


#ifdef __cplusplus
}
#endif

#endif
